/*
 * Copyright (c) 2016-2023 The gRPC-Spring Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.devh.boot.grpc.test.security;

import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

import lombok.extern.slf4j.Slf4j;
import net.devh.boot.grpc.test.config.BaseAutoConfiguration;
import net.devh.boot.grpc.test.config.ManualSecurityConfiguration;
import net.devh.boot.grpc.test.config.ServiceConfiguration;
import net.devh.boot.grpc.test.config.WithCertificateSecurityConfiguration;

@Slf4j
@SpringBootTest(properties = {
        "grpc.server.security.enabled=true",
        "grpc.server.security.certificateChain=file:src/test/resources/certificates/server.crt",
        "grpc.server.security.privateKey=file:src/test/resources/certificates/server.key",
        "grpc.server.security.trustCertCollection=file:src/test/resources/certificates/trusted-clients-collection",
        "grpc.server.security.clientAuth=REQUIRE",

        "grpc.client.GLOBAL.address=localhost:9090",
        "grpc.client.GLOBAL.security.authorityOverride=localhost",
        "grpc.client.GLOBAL.security.trustCertCollection=file:src/test/resources/certificates/trusted-servers-collection",
        "grpc.client.GLOBAL.security.clientAuthEnabled=true",

        "grpc.client.test.security.certificateChain=file:src/test/resources/certificates/client1.crt",
        "grpc.client.test.security.privateKey=file:src/test/resources/certificates/client1.key",

        "grpc.client.noPerm.security.certificateChain=file:src/test/resources/certificates/client2.crt",
        "grpc.client.noPerm.security.privateKey=file:src/test/resources/certificates/client2.key"
})
@SpringJUnitConfig(
        classes = {ServiceConfiguration.class, BaseAutoConfiguration.class, ManualSecurityConfiguration.class,
                WithCertificateSecurityConfiguration.class})
@DirtiesContext
class ManualSecurityWithCertificateTest extends AbstractSecurityTest {

    ManualSecurityWithCertificateTest() {
        log.info("--- ManualSecurityWithCertificateTest ---");
    }

}
